package com.sino.operation.controller;

import com.sino.operation.commons.response.CenterResponseEntity;
import com.sino.operation.param.out.EscReciveByCounter;
import com.sino.operation.peripheral.esc.response.EscResBody;
import com.sino.operation.peripheral.esc.response.EscResponseDto;
import com.sino.operation.service.business.StartServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * @Title: DepositAtNoticeController
 * @Description: 对公定期（通知）存款
 * @Author dengls
 * @date 2021/9/27 15:47
 */
@Slf4j
@RestController
@RequestMapping("depositAtNotice")
@Api(value = " 对公定期（通知）存款", tags = "对公定期（通知）存款的发起、查询等信息")
public class DepositAtNoticeController {

    @Autowired
    private StartServiceImpl startService;

    @PostMapping("startDepositAtNotice")
    @ApiOperation(value = "对公定期（通知）存款发起接口")
    public EscResponseDto startDepositAtNotice(@RequestBody @Valid EscReciveByCounter escReciveByCounter) {
        CenterResponseEntity<Object> build = CenterResponseEntity.build(Object.class);
        String parameter = null;
        try {
            parameter = startService.startTrans(escReciveByCounter);
        } catch (Exception e) {
            e.printStackTrace();
        }
        build.setData(parameter);
        EscResponseDto escReponse = new EscResponseDto();
        escReponse.setEscResBody(new EscResBody());
        escReponse.getEscResBody().setCenterResponseEntity(build);
        return escReponse;
    }
}
